Add _value API for number literals in proc-macro#154608
Conversation
This comment has been minimized.
This comment has been minimized.
ae03536 to
7cb03fd
Compare
|
My favourite kind of failure: works locally but not in CI. T_T Updated the value in the tests to see which one exactly is failing. |
This comment has been minimized.
This comment has been minimized.
7cb03fd to
c755b56
Compare
|
Bug comes from an issue with GCC proc-macro ABI. Ignoring this test on GCC backend for now. |
|
CI fixed. :) |
|
A libs (or maybe even libs-api) reviewer seems more appropriate to review this PR. r? Amanieu (since you reviewed #136355) |
|
I missed it already has an accepted ACP. The PR can be reviewed by libs reviewer. r? libs |
| Hexadecimal = 16, | ||
| } | ||
|
|
||
| fn parse_number(value: &str) -> (String, Base) { |
There was a problem hiding this comment.
Is this exactly in sync with what the rustc parser permits?
I guess that would be a mix of https://doc.rust-lang.org/nightly/reference/tokens.html#grammar-INTEGER_LITERAL and whatever we then tokenize from it?
Perhaps this should go over the bridge and ask rustc to parse the string for us?
There was a problem hiding this comment.
There is no code in rustc currently which would allow this conversion without including a lot of other things. My code is a simplified version of integer_lit (from rustc_ast/src/util/literal.rs) which parses both the number, its base and its suffix (which we already have) and returns a LitKind, which is also unnecessary here since we already know the end type.
There was a problem hiding this comment.
I think my question is not about specific code in rustc but rather whether the implementation here parses exactly the same literals that rustc would from the given token(s). Is that the case? Essentially, can we document these functions as being bug-for-bug compatible with what rustc would do, or do we need a separate grammar for this?
There was a problem hiding this comment.
At this point, the compiler already ran on the literal so all errors have been checked already. The remaining potential errors mostly come from trying to convert a int/float not fitting the expected output.
c755b56 to
ebb3161
Compare
This comment has been minimized.
This comment has been minimized.
|
Added the method for |
|
Forgot to change the status. @rustbot ready |
|
Can you reply to my comment here? #154608 (comment) @rustbot author |
|
Forgot to do so. Answered it. @rustbot ready |
This comment has been minimized.
This comment has been minimized.
…=<try> Add `_value` API for number literals in proc-macro try-job: x86_64-mingw-1
This comment has been minimized.
This comment has been minimized.
|
💔 Test for 1d1d12a failed: CI. Failed job:
|
This comment has been minimized.
This comment has been minimized.
e673d20 to
bd4bf50
Compare
|
@bors try jobs=x86_64-mingw-1 |
This comment has been minimized.
This comment has been minimized.
…=<try> Add `_value` API for number literals in proc-macro try-job: x86_64-mingw-1
This comment has been minimized.
This comment has been minimized.
bd4bf50 to
48c52ae
Compare
|
💔 Test for f7e180c failed: CI. Failed job:
|
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
@bors try jobs=x86_64-mingw-1 |
This comment has been minimized.
This comment has been minimized.
…=<try> Add `_value` API for number literals in proc-macro try-job: x86_64-mingw-1
|
@bors r=Mark-Simulacrum rollup |
…acro_API, r=Mark-Simulacrum Add `_value` API for number literals in proc-macro Part of rust-lang#136652. This PR adds the `*_value` for numbers (integers and floats). However, `f16` and `f128` are voluntarily left out as they're still unstable. Adding support for them is just a matter of uncommenting two lines, so should be fine. Setting same reviewer as last time. r? @Urgau
…uwer Rollup of 13 pull requests Successful merges: - #147302 (asm! support for the Xtensa architecture) - #148820 (Add very basic "comptime" fn implementation) - #157299 (Fix unstable diagnostics in tests) - #143511 (Improve TLS codegen by marking the panic/init path as cold) - #154608 (Add `_value` API for number literals in proc-macro) - #156762 (xfs support in `test_rename_directory_to_non_empty_directory`) - #157300 (Relax test requirements for consistency) - #157383 (tests: codegen-llvm: Ignore BPF targets in c-variadic-opt) - #157413 (fix: don't suggest .into_iter() for .cloned()/.copied() on non-reference Option) - #157578 (Fix diagnostics for non-exhaustive destructuring assignments (#157553)) - #157587 (explain that the size_of constant also serves to avoid optimizing away 'unused' size_of calls) - #157596 (test: remove ineffective link-extern-crate-with-drop-type test) - #157602 (rustdoc: Remove unnecessary fast path)
Rollup merge of #154608 - GuillaumeGomez:number_value_proc-macro_API, r=Mark-Simulacrum Add `_value` API for number literals in proc-macro Part of #136652. This PR adds the `*_value` for numbers (integers and floats). However, `f16` and `f128` are voluntarily left out as they're still unstable. Adding support for them is just a matter of uncommenting two lines, so should be fine. Setting same reviewer as last time. r? @Urgau
View all comments
Part of #136652.
This PR adds the
*_valuefor numbers (integers and floats). However,f16andf128are voluntarily left out as they're still unstable. Adding support for them is just a matter of uncommenting two lines, so should be fine.Setting same reviewer as last time.
r? @Urgau